#include "Menu.h"
#include <allegro.h>
#include <list>

using namespace std;

Menu::~Menu() {
    destroy_bitmap(mBackground);
}

BITMAP * Menu::getBackground(){
    return mBackground;
}

void Menu::setBackground(BITMAP * bg){
    mBackground = bg;
}

void Menu::addMenuItem(MenuItem * item){
    mItems.push_back(item);
}

void Menu::setFont(FONT * font){
    mFont = font;
}

BITMAP * Menu::draw(){
    list<MenuItem *>::iterator ci = mItems.begin();

    int i = 1; //increases for each iteration.
    while (ci != mItems.end()) {
        draw_sprite(getBackground(),
                (*ci)->getBitmap(),
                (*ci)->getXPos(),
                (*ci)->getYPos());
        
        //string text = (*ci)->getText();
        /*textout_ex(getBackground(), mFont, text.c_str(), (*ci)->getXPos(),
                (*ci)->getYPos(), 5, -1);*/
        ci++;
        i++;
    }

    return getBackground();
}

std::list<MenuItem*> Menu::getMenuItems() {
    return mItems;
}
